//
//  ThirdStyleCell.m
//  A段项目
//
//  Created by dllo on 16/1/26.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "ThirdStyleCell.h"
#import "Model.h"
#import <UIImageView+WebCache.h>
#import <DKNightVersion.h>

@interface ThirdStyleCell ()

@property (nonatomic, retain) UIImageView  *imageForPic;
@property (nonatomic, retain) UILabel      *labelOfDown;

@property (nonatomic, retain) UIImageView *leftestLabel;
@property (nonatomic, retain) UILabel *leftLabel;
@property (nonatomic, retain) UIImageView *rightLabel;
@property (nonatomic, retain) UILabel *rightestLabel;

@end

@implementation ThirdStyleCell

-(void)dealloc {
    
    [super dealloc];
    
    [_leftLabel release];
    [_leftestLabel release];
    [_rightLabel release];
    [_rightestLabel release];
    [_imageForPic release];
    [_labelOfDown release];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
 
#pragma mark --添加控件.
        self.imageForPic = [[UIImageView alloc] init];
        [self.contentView addSubview:self.imageForPic];
        
        self.labelOfDown = [[UILabel alloc] init];
        [self.contentView addSubview:self.labelOfDown];
        
        
        self.leftLabel = [[UILabel alloc] init];
        
        [self.contentView addSubview:self.leftLabel];
        
        self.leftestLabel = [[UIImageView alloc] init];
        
        [self.contentView addSubview:self.leftestLabel];
        
        self.rightLabel = [[UIImageView alloc] init];
        
        [self.contentView addSubview:self.rightLabel];
        
        self.rightestLabel = [[UILabel alloc] init];
        
        [self.contentView addSubview:self.rightestLabel];
        
        [_leftestLabel release];
        [_leftLabel release];
        [_rightestLabel release];
        [_rightLabel release];
        
        [_imageForPic release];
        [_labelOfDown release];
    }
    
    return self;
}

- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.imageForPic.frame = CGRectMake(5, 0, self.bounds.size.width - 10, 200);
    
    self.imageForPic.layer.cornerRadius = 4;
    
    self.imageForPic.layer.masksToBounds = YES;
    
    self.leftestLabel.frame = CGRectMake(10, 202, 16, 16);
    
    self.leftestLabel.image = [UIImage imageNamed:@"daojishi"];
    
    self.rightLabel.frame = CGRectMake(self.frame.size.width - 72, 202,16 , 16);
    
    self.rightLabel.image =[ UIImage imageNamed:@"tupian"];
    
    self.leftLabel.frame = CGRectMake(27, 202, 200, 16);
    
    self.rightestLabel.frame = CGRectMake(self.frame.size.width - 58, 202, 50, 16);
    
    self.labelOfDown.frame = CGRectMake(10, 218, self.frame.size.width - 20, 50);
    self.labelOfDown.numberOfLines = 2;
    
    self.labelOfDown.font = [UIFont systemFontOfSize:15];
    
    self.backgroundColor = [UIColor colorWithRed:0.6 green:0.6 blue:0.4 alpha:0.8];
    
    self.dk_backgroundColorPicker = DKColorWithColors([UIColor colorWithRed:0.6 green:0.6 blue:0.4 alpha:0.8], [UIColor colorWithRed:52 / 256.f green:52 / 256.f blue:52 / 256.f alpha:1]);
    
    self.labelOfDown.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    self.leftLabel.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
    self.rightestLabel.dk_textColorPicker = DKColorWithColors([UIColor blackColor], [UIColor whiteColor]);
    
}

- (void)passedInfo:(Model *)model {
    
    [self.imageForPic sd_setImageWithURL:[NSURL URLWithString:model.logoUrl]];
    
    self.labelOfDown.text = model.summary;
    
    
    NSString * timeStampString = model.endDate;
    NSDate *date = [NSDate dateWithTimeIntervalSince1970:[timeStampString doubleValue] / 1000];
 
    
    NSDate *date2 = [NSDate date];
    NSTimeInterval time = [date timeIntervalSinceDate:date2];
    
    NSInteger count = time/60/60/24;
    
    self.leftLabel.text = [NSString stringWithFormat:@"倒计时 %ld 天结束", count];
    
  
    
    self.leftLabel.font = [UIFont systemFontOfSize:12];
    
  NSInteger count1 = [model.imageCount doubleValue];

    self.rightestLabel.text = [NSString stringWithFormat:@" %ld ",count1];
    
    self.rightestLabel.font = [UIFont systemFontOfSize:12];
    
    
}



- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
